package com.lingxinst.business.main.vm

import android.view.MenuItem
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.lingxinst.business.main.R
import com.lingxinst.farm.base.vm.BaseViewModel

class MainViewModel : BaseViewModel() {
    private val _curMenuPos = MutableLiveData<Int>().apply {
        value = 0
    }
    val curMenuPos: LiveData<Int> = _curMenuPos


    fun onNavigationItemSelected(item: MenuItem): Boolean {
        // 校验是否登录，如未登录，跳转到登录页登录
        // 登录返回到指定菜单页
        when (item.itemId) {
            R.id.navigation_home -> {
                _curMenuPos.value = 0
            }

            R.id.navigation_channel -> {
                _curMenuPos.value = 1
            }

            R.id.navigation_dynamic -> {
                _curMenuPos.value = 2
            }

            R.id.navigation_mine -> {
                _curMenuPos.value = 3
            }

        }
        return true
    }
}